package cn.xiangyuanpin.tests;

import cn.xiangyuanpin.pojo.Cart;
import cn.xiangyuanpin.pojo.CartItem;
import org.junit.Test;

import java.math.BigDecimal;

import static org.junit.Assert.*;

public class CartTest {

    @Test
    public void addItem() {
        Cart cart=new Cart();
        cart.addItem(new CartItem(1,"java",1,new BigDecimal(100),new BigDecimal(100)));
        cart.addItem(new CartItem(1,"java",1,new BigDecimal(100),new BigDecimal(100)));
        cart.addItem(new CartItem(2,"数据结构",1,new BigDecimal(70),new BigDecimal(70)));
        System.out.println(cart);
    }

    @Test
    public void removeItem() {
        Cart cart=new Cart();
        cart.addItem(new CartItem(1,"java",1,new BigDecimal(100),new BigDecimal(100)));
        cart.addItem(new CartItem(1,"java",1,new BigDecimal(100),new BigDecimal(100)));
        cart.addItem(new CartItem(2,"数据结构",1,new BigDecimal(70),new BigDecimal(70)));
        System.out.println(cart);
        cart.removeItem(1);
        System.out.println(cart);
    }

    @Test
    public void clear() {
        Cart cart=new Cart();
        cart.addItem(new CartItem(1,"java",1,new BigDecimal(100),new BigDecimal(100)));
        cart.addItem(new CartItem(1,"java",1,new BigDecimal(100),new BigDecimal(100)));
        cart.addItem(new CartItem(2,"数据结构",1,new BigDecimal(70),new BigDecimal(70)));
        System.out.println(cart);
     cart.clear();
        System.out.println(cart);
    }

    @Test
    public void updateCount() {
        Cart cart=new Cart();
        cart.addItem(new CartItem(1,"java",1,new BigDecimal(100),new BigDecimal(100)));
        cart.addItem(new CartItem(1,"java",1,new BigDecimal(100),new BigDecimal(100)));
        cart.addItem(new CartItem(2,"数据结构",1,new BigDecimal(70),new BigDecimal(70)));
        cart.updateCount(1,5);
        System.out.println(cart);
    }

    @Test
    public void getTotalCount() {
    }

    @Test
    public void getTotalPrice() {
    }
}